package ai.masks;

import ai.Threat;
import model.Slot;

/**
 * Maschera: 
 * -
 * X
 * X
 * Y
 */
public class Slot3VMask extends Mask {

	@Override
	public Threat applyMask(Slot[][] board, int row, int col) {
		if (isMaskApplicable(row, col, board.length - 1, board[0].length - 1)) {
			Slot s = board[row][col];
			if (board[row-1][col] == s && board[row-2][col] == s
					&& board[row-3][col] == Slot.FREE)
			{
				Threat t = new Threat(row - 3, col, s, isThreatPlayable(board, row-3, col));
				t.setVertical(true);
				return t;
			}
				
			else
				return null;
		} else
			return null;
	}

	@Override
	protected int minRow(int boardRows, int boardCols) {
		return 3;
	}

	@Override
	protected int maxRow(int boardRows, int boardCols) {
		return boardRows;
	}

	@Override
	protected int minCol(int boardRows, int boardCols) {
		return 0;
	}

	@Override
	protected int maxCol(int boardRows, int boardCols) {
		return boardCols;
	}

}
